package com.lzy.cloud.base.service.impl;

import com.lzy.cloud.base.dto.BaseAreaRecordDto;
import com.lzy.cloud.base.entity.BaseAreaRecord;
import com.lzy.cloud.base.mapper.BaseAreaRecordMapperExt;
import com.lzy.cloud.base.service.AreaRecordService;
import com.lzy.framework.core.orm.db.Pager;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AreaRecordServiceImpl implements AreaRecordService {

    @Autowired
    private BaseAreaRecordMapperExt baseAreaRecordMapperExt;


    @Override
    public Long insert(BaseAreaRecordDto baseAreaRecordDto) {
        BaseAreaRecord baseAreaRecord = DozerUtils.map(baseAreaRecordDto, BaseAreaRecord.class);
        return baseAreaRecordMapperExt.insertSelective(baseAreaRecord) > 0 ? baseAreaRecord.getId() : 0;
    }

    @Override
    public int update(BaseAreaRecordDto baseAreaRecordDto) {
        return baseAreaRecordMapperExt.updateByPrimaryKeySelective(DozerUtils.map(baseAreaRecordDto, BaseAreaRecord.class));
    }

    @Override
    public Boolean delete(Long aLong) {
        return null;
    }

    @Override
    public Boolean remove(Long aLong) {
        return null;
    }

    @Override
    public BaseAreaRecordDto findById(Long aLong) {
        return DozerUtils.map(baseAreaRecordMapperExt.selectByPrimaryKey(aLong), BaseAreaRecordDto.class);
    }

    @Override
    public List<BaseAreaRecordDto> query(Pager pager, BaseAreaRecordDto baseAreaRecordDto) {
        return null;
    }

    @Override
    public List<BaseAreaRecordDto> getList() {
        return baseAreaRecordMapperExt.getList();
    }

    @Override
    public List<BaseAreaRecordDto> getListByObject(BaseAreaRecordDto baseAreaRecordDto) {
        return baseAreaRecordMapperExt.getListByObject(baseAreaRecordDto);
    }

    @Override
    public BaseAreaRecordDto findAreaByCode(Integer code) {
        return baseAreaRecordMapperExt.findAreaByCode(code);
    }

}
